package Depression;


import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;



public class Indicator{
	
	public String name;
	public int value;
	public boolean consecutiveVisits;	
	public static ArrayList<Indicator> indicators;
	
   
	public Indicator() {
		Indicator.messages = new ArrayList<String>();
		Indicator.indicators = new ArrayList<Indicator>();
		//this.consecutiveVisits=true;
	}
	public Indicator(boolean consecutiveVisits) {
		this.consecutiveVisits=consecutiveVisits;
	}
	
	 public boolean isConsecutiveVisits() {
	    return consecutiveVisits=true;
	}

	public void setConsecutiveVisits(boolean consecutiveVisits) {
	    this.consecutiveVisits = consecutiveVisits;
	}

	public Indicator(String name,int value) {
		this();
		this.name = name;
		this.value = value;
		
		
	}
	
	public String getName() {
		return name;
	}
	
	public int getValue() {
		return value;
	}
	
	public void setValue(int value) {
		this.value = value;
	}
	
	public int count(String s,int b){
		int c=1;
		 //Indicator[] i=(Indicator[])(indicators.toArray());
		for(int a=0;a<indicators.size();a++){      	
         if(((indicators.get(a)).name)==s&&((indicators.get(a)).value)>=b){
        	 c=c+1; 
        }
         a++;}
		return c;	
	
	}
	
		
	
	public ArrayList<Indicator> getIndicators() {
		return indicators;
	}
	public static void setIndicators(ArrayList<Indicator> indicators) {
		Indicator.indicators = indicators;
	}
	
	
	public static void addToIndicators(Indicator i) {
		indicators.add(i);
		
	}

	public void setName(String name) {
		this.name = name;
	}
	public static Date addDays(Date date, int days) {
	   	Calendar cal = Calendar.getInstance();
	 	cal.setTime(date);
	 	cal.add(Calendar.DATE,days);
	 	  return cal.getTime();
	   }

	public static String format(Date date) {
  	  DateFormat formatter = DateFormat.getDateInstance();
  	  return formatter.format(date);
    }
	
	public String toString() {
		return name+", "+", "+value;
	}
	
	public static Collection<String>  messages;
	
	public static void setMessages(Collection<String> messages) {
		Indicator.messages = messages;
	}

	public Collection<String> getMessages() {
		return messages;
	}
	
	public void removeFromMessages (String argument) {
		messages.remove(argument);
	}
	
	public static void addToMessages (String argument) {
		if(!messages.contains(argument)){
		messages.add("\n"+argument);}
		else
			messages.add(null);
		
	}
	
		
}
